package yudisium;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public class PanelPeriksaYudisium extends JPanel {

    private JLabel labelPanel;
    private JLabel labelNim;
    private JTextField textNim;
    private JButton tombolPeriksa;
    private JButton tombolBatal;

    public PanelPeriksaYudisium() {

        setLayout(null);

        labelPanel = new JLabel("Panel Periksa Yudisium");
        labelPanel.setBounds(190, 15, 200, 40);
        add(labelPanel);

        labelNim = new JLabel("Nim");
        labelNim.setBounds(50, 90, 100, 50);
        add(labelNim);

        textNim = new JTextField();
        textNim.setBounds(150, 100, 270, 32);
        textNim.setBackground(Color.WHITE);
        add(textNim);

        tombolPeriksa = new JButton("Periksa");
        tombolPeriksa.setBounds(95, 280, 110, 30);
        add(tombolPeriksa);
        tombolPeriksa.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                tombolPeriksaAction();
            }
        });

        tombolBatal = new JButton("Batal");
        tombolBatal.setBounds(290, 280, 110, 30);
        add(tombolBatal);
        tombolBatal.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                tombolBatalAction();
            }
        });

        setVisible(true);
    }

    private PanelPeriksaYudisium(ArrayList<Yudisium> DAFTAR_MAHASISWA) {
        
    }

    public void tombolPeriksaAction() {
        if (textNim.getText().isEmpty()) {
            try {
                throw new Exception("Nim harus terisi");
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage());
                Logger.getLogger(PanelPeriksaYudisium.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
//            PengendaliPemeriksaanYudisium.LihatTabelMaha;
            
//             public void tombolSimpanAction() {
//        Yudisium yud = new Yudisium();
//        yud.setNama(getTextNama().getText());
//        yud.setNim(getTextNim().getText());
//        yud.setNomorHp(getTextNoHp().getText());
//        yud.setProdi(getTextEmail().getText());
//        yud.setPerYud(getTextPeriode().getText());
//        

            Yudisium yd = new Yudisium();
            JDialog testFrame = new JDialog();
            yd.setNim(textNim.getText());
            PengendaliPemeriksaanYudisium.periksaDataYudisium(yd);
            if (PengendaliPendaftaranYudisium.getDAFTAR_MAHASISWA().isEmpty()) {
            if (PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Data tidak ada. .");
            } else {
                PanelPeriksaYudisium test = new PanelPeriksaYudisium(PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA);
                testFrame.getContentPane().add(test);
                testFrame.setSize(1367, 765);
                testFrame.setVisible(true);
                testFrame.setTitle("Panel Periksa Yudisium");
            }
        }
    }
    }

    public void tombolBatalAction() {
        System.exit(0);
    }
}
